EasyCameraAndGallery

Additional

Language
Kotlin
Version
1.0.0 (Aug 1, 2022)
Created
Jul 25, 2022
Updated
Aug 1, 2022 (Retired)
Owner
Alfredo Hernández (AlfredoHdez1709)
Contributor
Alfredo Hernández (AlfredoHdez1709)
1
Activity
N/A
Badge
Generate
Download
Source code

Advertisement

EasyCameraAndGallery

Get Permission Home Camera Select photo Send result

Install

Support API 21 and above

Step 1. Add it in your root build.gradle at the end of repositories:

maven { url 'https://jitpack.io' }

Step 2. Add the dependency

implementation 'com.github.AlfredoHdez1709:EasyCameraAndGallery:{version}'

Basic implementation

Generate call result from an activity

returns a list with paths of captured or selected images (List)

    private lateinit var resultScan: ActivityResultLauncher<Intent>

    private fun initCall() {
        resultScan = registerForActivityResult(androidx.activity.result.contract.
        ActivityResultContracts.StartActivityForResult()) { result ->
                if (result.resultCode == Activity.RESULT_OK) {
                    val list = result.data?.getStringArrayListExtra(EasyCamera.IMAGE_RESULTS)
                    print(list)
                }
            }
    }

Launch the camera send as parameter the context, options and result

EasyCamera.start(this, OptionsCamera(), resultScan)

Custom implementation

val optionsCamera = OptionsCamera(
            count = 1,
            path = "CustomFolder",
            flash = Flash.Auto,
            isFrontFacing = true,
            ratio = Ratio.RATIO_16_9
        )

EasyCamera.start(this, optionsCamera, resultScan)
Attributes Type Note
count Int Number of captured images.
path String Folder where the images are saved. pictures/customFolder
flash Flash Control the flash of your implementation.
isFrontFacing Boolean Turn on the front camera by default.
ratio Ration Control the dimensions of your captured image.

Thanks to

License

Licensed under MIT, click here for the full license.

Author & support

This project was created by AHRSOFT.

If you appreciate my work, consider buying me a cup of ☕ to keep me recharged ???? by PayPal